package sky.demos.springboot.rest;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/version")
public class VersionController {
	@Autowired
	private final CounterService counterService;
	@Autowired
	private final GaugeService gaugeService;

	public VersionController(CounterService counterService, GaugeService gaugeService) {
		this.counterService = counterService;
		this.gaugeService = gaugeService;
	}

	@RequestMapping(method = RequestMethod.GET)
	public @ResponseBody HashMap<String, Object> version() {
		counterService.increment("version.get");
		HashMap<String, Object> ret = new HashMap<String, Object>();
		ret.put("0.0.1", "demo spring boot");
		return ret;
	}
}